<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>登录 - DICOM 管理系统</title>
    <link href="lib/bootstrap/css/bootstrap.min.css" rel="stylesheet">
    <link href="lib/bootstrap-icons/bootstrap-icons.css" rel="stylesheet">
    <link rel="icon" type="image/x-icon" href="/favicon.ico">
    <style>
        body {
            height: 100vh;
            background: linear-gradient(135deg, rgba(0,0,0,0.6), rgba(0,0,0,0.3)), 
                        url('images/login-bg.jpg') no-repeat center center;
            background-size: cover;
            display: flex;
            align-items: center;
            justify-content: center;
        }

        .login-container {
            background: rgba(255, 255, 255, 0.95);
            padding: 2.5rem;
            border-radius: 15px;
            box-shadow: 0 8px 32px rgba(0, 0, 0, 0.1);
            backdrop-filter: blur(10px);
            width: 100%;
            max-width: 420px;
        }

        .logo-container {
            text-align: center;
            margin-bottom: 2.5rem;
        }

        .logo-container img {
            width: 100px;
            height: auto;
            margin-bottom: 1.2rem;
            transition: transform 0.3s ease;
        }

        .logo-container img:hover {
            transform: scale(1.05);
        }

        .logo-container h4 {
            color: #2c3e50;
            margin: 0;
            font-weight: 600;
            font-size: 1.5rem;
        }

        .form-label {
            color: #34495e;
            font-weight: 500;
            font-size: 0.9rem;
            margin-bottom: 0.5rem;
        }

        .form-control {
            border: 2px solid #eee;
            padding: 0.6rem 1rem;
            border-radius: 8px;
            transition: all 0.3s ease;
        }

        .form-control:focus {
            border-color: #3498db;
            box-shadow: 0 0 0 0.2rem rgba(52, 152, 219, 0.15);
        }

        .input-group {
            position: relative;
        }

        .input-icon {
            position: absolute;
            left: 1rem;
            top: 50%;
            transform: translateY(-50%);
            color: #95a5a6;
            z-index: 10;
            transition: color 0.3s ease;
            pointer-events: none;
        }

        .input-with-icon {
            padding-left: 2.8rem !important;
        }

        .btn-primary {
            background: linear-gradient(135deg, #3498db, #2980b9);
            border: none;
            padding: 0.8rem;
            font-weight: 500;
            letter-spacing: 0.5px;
            border-radius: 8px;
            transition: all 0.3s ease;
        }

        .btn-primary:hover {
            background: linear-gradient(135deg, #2980b9, #2573a7);
            transform: translateY(-1px);
            box-shadow: 0 4px 15px rgba(52, 152, 219, 0.3);
        }

        .alert {
            border-radius: 8px;
            font-size: 0.9rem;
            border: none;
        }

        .copyright {
            position: fixed;
            bottom: 1.5rem;
            width: 100%;
            text-align: center;
            color: rgba(255, 255, 255, 0.9);
            font-size: 0.9rem;
            text-shadow: 1px 1px 2px rgba(0, 0, 0, 0.5);
        }

        @media (max-width: 576px) {
            .login-container {
                margin: 1rem;
                padding: 2rem;
            }
        }

        .input-group:focus-within .input-icon {
            color: #3498db;
        }
    </style>
</head>
<body>
    <div class="login-container">
        <div class="logo-container">
            <img src="images/logo.png" alt="Logo">
            <h4>DICOM 管理系统</h4>
        </div>
        <form id="loginForm" onsubmit="return false;">
            <div class="alert alert-danger" style="display: none;" id="error-message"></div>
            <div class="mb-3">
                <label class="form-label">用户名</label>
                <div class="input-group">
                    <i class="bi bi-person input-icon"></i>
                    <input type="text" class="form-control input-with-icon" id="username" placeholder="请输入用户名" required autofocus>
                </div>
            </div>
            <div class="mb-3">
                <label class="form-label">密码</label>
                <div class="input-group">
                    <i class="bi bi-lock input-icon"></i>
                    <input type="password" class="form-control input-with-icon" id="password" placeholder="请输入密码" required>
                </div>
            </div>
            <div class="d-grid mt-4">
                <button type="button" class="btn btn-primary" onclick="login()">
                    登录系统
                </button>
            </div>
        </form>
    </div>

    <div class="copyright">

            © 2024 DICOM管理系统 by 
            <a href="https://gitee.com/fightroad/DicomSCP" target="_blank">
                平凡之路 <i class="bi bi-github"></i>
            </a>

    </div>

    <script src="lib/jquery/jquery.min.js"></script>
    <script src="lib/bootstrap/js/bootstrap.bundle.min.js"></script>
    <script src="lib/axios/axios.min.js"></script>
    <script>
        async function login() {
            const username = document.getElementById('username').value;
            const password = document.getElementById('password').value;
            const errorMessage = document.getElementById('error-message');
            
            try {
                await axios.post('/api/auth/login', { username, password });
                
                // 登录成功，跳转到首页
                window.location.href = '/';
            } catch (error) {
                errorMessage.style.display = 'block';
                errorMessage.textContent = error.response?.data || error.message || '登录失败';
                setTimeout(() => {
                    errorMessage.style.display = 'none';
                }, 3000);
            }
        }

        // 添加回车键登录支持
        document.getElementById('loginForm').addEventListener('keypress', function(e) {
            if (e.key === 'Enter') {
                login();
            }
        });
    </script>
</body>
</html> 